#include "socketmanager.h"

Socket::ptr SocketManager::get()
{
    return std::make_shared<Socket>();
}

Socket::ptr SocketManager::get(int fd)
{
    if(m_sockets.count(fd) == 0)
    {
        Socket::ptr socket(new Socket(fd));
        m_sockets[fd] = socket;
        return socket;
    }
    else
    {
        return m_sockets[fd];
    }
}

void SocketManager::del(int fd)
{
    if(m_sockets.count(fd) != 0)
    {
        m_sockets[fd].reset();
        m_sockets.erase(fd);
    }
}